home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-04-21 | 2.2 KB | 78 lines | [TEXT/MPS ] |
- // The C++ Booch Components (Version 2.1)
- // (C) Copyright 1990-1993 Grady Booch. All Rights Reserved.
- //
- // BCUnboun.h
- //
- // This file contains the declaration of the list-based class
- // used for the representation of unbounded structures.
-
- #ifndef BCUNBOUN_H
- #define BCUNBOUN_H 1
-
- #include <stddef.h>
- #include "BCExcept.h"
- #include "BCNodes.h"
-
- // Class denoting a list-based container
-
- template<class Item, class StorageManager>
- class BC_TUnbounded {
- public:
-
- BC_TUnbounded();
- BC_TUnbounded(const BC_TUnbounded<Item, StorageManager>&);
- ~BC_TUnbounded();
-
- BC_TUnbounded<Item, StorageManager>&
- operator=(const BC_TUnbounded<Item, StorageManager>&);
- BC_Boolean operator==(const BC_TUnbounded<Item, StorageManager>&) const;
- BC_Boolean operator!=(const BC_TUnbounded<Item, StorageManager>& c) const
- {return !operator==(c);}
- const Item& operator[](BC_Index index) const
- {BC_Assert((index < Length()),
- BC_XRangeError("BC_TUnbounded<>::operator[]", BC_kInvalidIndex));
- return ItemAt(index);}
- Item& operator[](BC_Index index)
- {BC_Assert((index < Length()),
- BC_XRangeError("BC_TUnbounded<>::operator[]", BC_kInvalidIndex));
- return ItemAt(index);}
-
- void Clear();
- void Insert(const Item&);
- void Insert(const Item&, BC_Index before);
- void Append(const Item&);
- void Append(const Item&, BC_Index after);
- void Remove(BC_Index at);
- void Replace(BC_Index at, const Item&);
-
- BC_Index Length() const;
- const Item& First() const
- {BC_Assert(fSize, BC_XUnderflow("BC_TUnbounded<>::First()", BC_kEmpty));
- return (fRep->fItem);}
- Item& First()
- {BC_Assert(fSize, BC_XUnderflow("BC_TUnbounded<>::First()", BC_kEmpty));
- return (fRep->fItem);}
- const Item& Last() const
- {return (fLast->fItem);}
- Item& Last()
- {return (fLast->fItem);}
- const Item& ItemAt(BC_Index index) const;
- Item& ItemAt(BC_Index index);
- BC_ExtendedIndex Location(const Item&, BC_Index start = 0) const;
-
- static void* operator new(size_t);
- static void operator delete(void*, size_t);
-
- protected:
-
- BC_TNode<Item, StorageManager>* fRep;
- BC_TNode<Item, StorageManager>* fLast;
- BC_Index fSize;
-
- BC_TNode<Item, StorageManager>* fCache;
- BC_Index fCacheIndex;
-
- };
-
- #endif
-